package com.example.websocketdemo.API;

import com.alibaba.fastjson.JSON;
import com.example.websocketdemo.entity.video.Cameras;
import com.example.websocketdemo.entity.video.PreviewURLs;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;

import java.util.HashMap;
import java.util.Map;


/**
 * Auto Create on 2021-10-15 02:26:00
 */
public class VideoTwoApi {
	static {
		ArtemisConfig.host = "192.168.7.100:443";
		ArtemisConfig.appKey = "28238188"; // 秘钥appkey
		ArtemisConfig.appSecret = "AlDrRjv7JLfP9S8N3LxW";
	}

	/**
	 * STEP2：设置OpenAPI接口的上下文
	 */
	private static final String ARTEMIS_PATH = "/artemis";

	//获取视频设备信息
	public String C(Cameras cameras) {
		String getDataApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
		Map<String, String> path = new HashMap<String, String>(2) {
			{
				put("https://", getDataApi);
			}
		};
		String body = JSON.toJSONString(cameras);
		String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json");
		return result;
	}

	//获取视频设备信息
	public String P(PreviewURLs previewURLs) {
		String getDataApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs";
		Map<String, String> path = new HashMap<String, String>(2) {
			{
				put("https://", getDataApi);
			}
		};
		String body = JSON.toJSONString(previewURLs);
		String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json");
		return result;
	}

}
